//class TxtRemoteDataProxy
package baidu.reader.txt.model
{
    import baidu.reader.common.model.*;
    import baidu.ui.managers.*;
    import flash.events.*;
    import flash.net.*;
    import flash.utils.*;

    internal class TxtRemoteDataProxy extends flash.events.EventDispatcher
    {
        public function TxtRemoteDataProxy(arg1:flash.events.IEventDispatcher=null)
        {
            this._urlLoader = new flash.net.URLLoader();
            super(arg1);
            this._urlLoader.dataFormat = flash.net.URLLoaderDataFormat.BINARY;
            this._urlLoader.addEventListener(flash.events.Event.COMPLETE, this.dataCompleteHandler);
            this._urlLoader.addEventListener(flash.events.IOErrorEvent.IO_ERROR, this.errorHandler);
            this._urlLoader.addEventListener(flash.events.SecurityErrorEvent.SECURITY_ERROR, this.errorHandler);
            return;
        }

        private function errorHandler(arg1:flash.events.Event):void
        {
            dispatchEvent(new flash.events.Event(flash.events.ErrorEvent.ERROR));
            return;
        }

        private function dataCompleteHandler(arg1:flash.events.Event):void
        {
            this._data = this._urlLoader.data;
            dispatchEvent(arg1);
            return;
        }

        public function load(arg1:String, arg2:int, arg3:int):void
        {
            var loc1:*;
            loc1 = arg2 * arg3 + 1;
            var loc2:*;
            loc2 = (baidu.ui.managers.InstanceManager.createSingletonInstance(baidu.reader.common.model.AppConfigModel) as baidu.reader.common.model.AppConfigModel).getContentURL(arg1, "pn=" + loc1 + "&rn=" + arg3);
            this._urlLoader.load(new flash.net.URLRequest(loc2));
            return;
        }

        public function get data():flash.utils.ByteArray
        {
            return this._data;
        }

        private var _urlLoader:flash.net.URLLoader;

        private var _data:flash.utils.ByteArray;
    }
}


